package org.lizar.controller;

import java.net.InetAddress;

import javax.servlet.http.HttpServletRequest;

public class NetTool {

	    /**
	     * a判断请求的ip是否是当前集群ip
	     * @param address 需要判断的ip地址
	     * @return true:是反向代理服务器地址; false:不是反向代理服务器地址，用户真实地址
	     */
		 public boolean isCluster(InetAddress address) {

	            return !address.isSiteLocalAddress();

		 }


	    /**
	     * 从当前request头中获得用户的ip
	     *
	     * @param request 当前request
	     * @return ip
	     */
		 public String getRemoteAddressByRequest(HttpServletRequest request) {
	            return request.getHeader("x-forwarded-for");
	     }
	    

}
